/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CapaPresentacion;

import CapaLogica.Gestor;
import CapaLogica.Obra;
import java.util.ArrayList;
import java.util.Date;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.ListModel;

/**
 *
 * @author Elayner
 */
public class PantallaGaleriaEditar extends javax.swing.JFrame {

    private String nombre;
    private String direccion;
    private String telefono;
    private String fec_ina;
    private String nomEncargado;
    private String dimension;
    private static Gestor gestor=new Gestor();
    private Date fechaActual=new Date();
    private ArrayList<TreeMap> listaObras;
    private TreeMap infoListaObras;
    private DefaultListModel modelo = new DefaultListModel();
    private TreeMap infoGaleria;

    /**
     * Creates new form PantallaGaleriaAgregar
     */
    public PantallaGaleriaEditar() {
        initComponents();
    }
    
   public PantallaGaleriaEditar(String pnombre) throws Exception {
        initComponents();
        loadScreenGaleria(pnombre);
        fec_ina_gal.setMaxSelectableDate(fechaActual);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        dir_gal = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        btn_actualizar = new javax.swing.JButton();
        btn_cencelar = new javax.swing.JButton();
        nom_gal = new javax.swing.JTextField();
        tel_gal = new javax.swing.JTextField();
        dmen_gal = new javax.swing.JTextField();
        nom_eng_gal = new javax.swing.JTextField();
        fec_ina_gal = new com.toedter.calendar.JDateChooser();
        jScrollPane1 = new javax.swing.JScrollPane();
        list_obras = new javax.swing.JList();
        jLabel7 = new javax.swing.JLabel();
        btn_exponer = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        btn_noexpo = new javax.swing.JButton();
        btn_elim_obra = new javax.swing.JButton();
        btn_Edittar_obra = new javax.swing.JButton();
        fecha_de = new com.toedter.calendar.JDateChooser();
        fecha_hasta = new com.toedter.calendar.JDateChooser();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        btn_reporte = new javax.swing.JButton();
        btn_clear = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Editar Galeria");

        jLabel1.setText("Nombre de la galeria:");

        jLabel2.setText("Dirección:");

        dir_gal.setColumns(20);
        dir_gal.setRows(5);
        jScrollPane2.setViewportView(dir_gal);

        jLabel3.setText("Telefono:");

        jLabel4.setText("Fecha inaguracion:");

        jLabel5.setText("Dimensiones:");

        jLabel6.setText("Nombre Encargado:");

        btn_actualizar.setText("Actualizar");
        btn_actualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_actualizarActionPerformed(evt);
            }
        });

        btn_cencelar.setText("Cancelar");
        btn_cencelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cencelarActionPerformed(evt);
            }
        });

        nom_gal.setEditable(false);

        jScrollPane1.setViewportView(list_obras);

        jLabel7.setText("Lista de obras:");

        btn_exponer.setText("Expo.In");
        btn_exponer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_exponerActionPerformed(evt);
            }
        });

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        btn_noexpo.setText("Exp.Out");
        btn_noexpo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_noexpoActionPerformed(evt);
            }
        });

        btn_elim_obra.setText("Eliminar");
        btn_elim_obra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_elim_obraActionPerformed(evt);
            }
        });

        btn_Edittar_obra.setText("Editar");
        btn_Edittar_obra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_Edittar_obraActionPerformed(evt);
            }
        });

        fecha_de.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                fecha_dePropertyChange(evt);
            }
        });

        jLabel8.setText("Listar por rango de fechas de adquisicion");

        jLabel9.setText("Fecha de:");

        jLabel10.setText("Fecha hasta:");

        btn_reporte.setText("Generar");
        btn_reporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_reporteActionPerformed(evt);
            }
        });

        btn_clear.setText("Limpiar");
        btn_clear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_clearActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(nom_gal, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(50, 50, 50)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(fec_ina_gal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(tel_gal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)))))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addGap(18, 18, 18)
                                .addComponent(dmen_gal, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(nom_eng_gal, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addComponent(btn_actualizar)
                        .addGap(54, 54, 54)
                        .addComponent(btn_cencelar)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addComponent(jLabel8))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btn_exponer)
                                    .addComponent(btn_noexpo)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(btn_Edittar_obra, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(btn_elim_obra, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                            .addComponent(jLabel7)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel10))
                                .addGap(37, 37, 37)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(fecha_hasta, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(fecha_de, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addComponent(btn_reporte)
                        .addGap(59, 59, 59)
                        .addComponent(btn_clear)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(nom_gal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(tel_gal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel4)
                            .addComponent(fec_ina_gal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(13, 13, 13)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(dmen_gal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(nom_eng_gal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(98, 98, 98)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btn_actualizar)
                            .addComponent(btn_cencelar)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(btn_exponer)
                                .addGap(18, 18, 18)
                                .addComponent(btn_noexpo)
                                .addGap(18, 18, 18)
                                .addComponent(btn_elim_obra)
                                .addGap(18, 18, 18)
                                .addComponent(btn_Edittar_obra))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(fecha_de, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(fecha_hasta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btn_reporte)
                            .addComponent(btn_clear))))
                .addGap(33, 49, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_actualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_actualizarActionPerformed
        try {
            nombre=nom_gal.getText();
            direccion=dir_gal.getText();
            telefono=tel_gal.getText();
            fec_ina=helperUI.getDateFormatConv(fec_ina_gal.getDate());
            nomEncargado=nom_eng_gal.getText();
            dimension=dmen_gal.getText();
            gestor.actualizarGaleria(nombre, direccion, telefono, fec_ina, nomEncargado, dimension);
            this.setVisible(false);
        } catch (Exception ex) {
            Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_actualizarActionPerformed

    private void btn_cencelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cencelarActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_btn_cencelarActionPerformed

    private void btn_exponerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_exponerActionPerformed
        if(!list_obras.isSelectionEmpty()){
                try {
                    gestor.actualizaIndExpo(true, getCodObraFromList());
                    listaObras=gestor.buscarObrasPorGaleria(nom_gal.getText());
                    clearList();
                    loadListObras();
            } catch (Exception ex) {
                Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(Level.SEVERE, null, ex);
            }
        }else{
            JOptionPane.showMessageDialog(this,(String) "Debe de seleccionar una opcion","Error",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btn_exponerActionPerformed

    private void btn_Edittar_obraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_Edittar_obraActionPerformed
        try {
            if(!list_obras.isSelectionEmpty()){
                PantallaObraEditar Editar_Obra;
                Editar_Obra = new PantallaObraEditar(getCodObraFromList());
                Editar_Obra.setVisible(true);
            }else{
                JOptionPane.showMessageDialog(this,(String) "Debe de seleccionar una opcion","Error",JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception ex) {
            Logger.getLogger(PantallaArtistaBuscar.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_Edittar_obraActionPerformed

    private void btn_elim_obraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_elim_obraActionPerformed
        try {
            if(!list_obras.isSelectionEmpty()){
                gestor.eliminarObra(getCodObraFromList());
                listaObras=gestor.buscarObrasPorGaleria(nom_gal.getText());
                clearList();
                loadListObras();
            }else{
                JOptionPane.showMessageDialog(this,(String) "Debe de seleccionar una opcion","Error",JOptionPane.ERROR_MESSAGE);
            }
            
        } catch (Exception ex) {
            Logger.getLogger(PantallaObraBuscar.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_elim_obraActionPerformed

    private void btn_noexpoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_noexpoActionPerformed
        if(!list_obras.isSelectionEmpty()){
            try {
                gestor.actualizaIndExpo(false,getCodObraFromList());
                listaObras=gestor.buscarObrasPorGaleria(nom_gal.getText());
                clearList();
                loadListObras();
            } catch (Exception ex) {
                Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(Level.SEVERE, null, ex);
            }
        }else{
            JOptionPane.showMessageDialog(this,(String) "Debe de seleccionar una opcion","Error",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btn_noexpoActionPerformed

    private void btn_reporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_reporteActionPerformed
        if(fecha_de.getDate()!=null && fecha_hasta.getDate()!=null){
            try {
                String fehaDe=helperUI.getDateFormatConv(fecha_de.getDate());
                String fehaHasta=helperUI.getDateFormatConv(fecha_hasta.getDate());
                listaObras=gestor.buscarObrasPorGaleriaFechas(nom_gal.getText(), fehaDe, fehaHasta);
                clearList();
                loadListObras();
            } catch (Exception ex) {
                Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(Level.SEVERE, null, ex);
            }
           
        }else{
             JOptionPane.showMessageDialog(this,(String) "Debe de seleccionar una rango de fechas valido","Error",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btn_reporteActionPerformed

    private void fecha_dePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_fecha_dePropertyChange
        fecha_hasta.setMinSelectableDate(fecha_de.getDate());
        fecha_hasta.setMaxSelectableDate(fechaActual);        
    }//GEN-LAST:event_fecha_dePropertyChange

    private void btn_clearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_clearActionPerformed
        try {
            fecha_de.setDate(null);
            fecha_hasta.setDate(null);
            listaObras=gestor.buscarObrasPorGaleria(nom_gal.getText());
            clearList();
            loadListObras();
        } catch (Exception ex) {
            Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_clearActionPerformed

    private void loadScreenGaleria(String pnombre) throws Exception{
        infoGaleria=gestor.buscarInfoGeneralGaleria(pnombre);

        if(infoGaleria!=null){
            nom_gal.setText((String)infoGaleria.get("nombre"));
            dir_gal.setText((String)infoGaleria.get("direccion"));
            tel_gal.setText((String)infoGaleria.get("ptelefono"));
            fec_ina_gal.setDate(helperUI.getDateFormatDate((String)infoGaleria.get("fec_ina")));
            dmen_gal.setText((String)infoGaleria.get("dimension"));
            nom_eng_gal.setText((String)infoGaleria.get("nom_encargado"));
            listaObras=gestor.buscarObrasPorGaleria(nom_gal.getText());
            if(listaObras!=null)
                loadListObras();
        }
    }
    
   private boolean validarPantalla(){
        boolean result=true;
        
        if(nom_gal.getText().length()<=0)
            result=false;
        if(dir_gal.getText().length()<=0)
            result=false;
        if(tel_gal.getText().length()<=0)
            result=false;
        if(fec_ina_gal.getDate()==null)
            result=false;
        if(nom_eng_gal.getText().length()<=0)
            result=false;
        if(dmen_gal.getText().length()<=0)
            result=false;
        
        return result;
    }
   
   private String getCodObraFromList(){
        int index=list_obras.getSelectedIndex();
        String idObra="";
        if(index!=-1)
            idObra=(String)listaObras.get(index).get("codigo");
        
        return idObra;
   }
   
   private void loadListObras(){
       
     if(listaObras!=null){
        for(int i=0,j=1;i<listaObras.size();i++,j++){
            infoListaObras=listaObras.get(i);
            String isExpo=(boolean)infoListaObras.get("indExpo")?"Exp":"No EXP";
            modelo.addElement(j+"."+infoListaObras.get("nombre")+"-"+infoListaObras.get("artista")+"-"+infoListaObras.get("costo")+"-"+isExpo);
        }
        list_obras.setModel(modelo);
    }
    
   }
   
  private void clearList(){
        modelo=(DefaultListModel)list_obras.getModel();
        modelo.removeAllElements();
   }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PantallaGaleriaEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new PantallaGaleriaEditar().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_Edittar_obra;
    private javax.swing.JButton btn_actualizar;
    private javax.swing.JButton btn_cencelar;
    private javax.swing.JButton btn_clear;
    private javax.swing.JButton btn_elim_obra;
    private javax.swing.JButton btn_exponer;
    private javax.swing.JButton btn_noexpo;
    private javax.swing.JButton btn_reporte;
    private javax.swing.JTextArea dir_gal;
    private javax.swing.JTextField dmen_gal;
    private com.toedter.calendar.JDateChooser fec_ina_gal;
    private com.toedter.calendar.JDateChooser fecha_de;
    private com.toedter.calendar.JDateChooser fecha_hasta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JList list_obras;
    private javax.swing.JTextField nom_eng_gal;
    private javax.swing.JTextField nom_gal;
    private javax.swing.JTextField tel_gal;
    // End of variables declaration//GEN-END:variables
}
